package com.web.type;

import com.bean.Articletype;
import com.service.ArticleTypeService;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpdateArticleTypeServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Articletype type=new Articletype();
        ArticleTypeService service=new ArticleTypeService();

        try{
            BeanUtils.populate(type,req.getParameterMap());
            //System.out.println(type);
            service.updateType(type);
            req.getRequestDispatcher("/ListType").forward(req, resp);
        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
